/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package de.saar.penguin.give2.server.alert;

import de.saar.penguin.give2.server.BigBrother;
import de.saar.penguin.give2.server.Instruction;
import de.saar.penguin.give2.server.SaarNlgSystem;
import give.formula.Position;

/**
 *
 * @author koller
 */
public class NotFacingPositionAlert extends Alert {
    private Position targetPosition;

    public NotFacingPositionAlert(SaarNlgSystem nlg, Position targetPosition) {
        super(nlg);
        this.targetPosition = targetPosition;
    }

    @Override
    public boolean isActivated(BigBrother bb) {
        boolean thisTime = !FacingPositionAlert.playerLooksAt(nlg.getWorld(), targetPosition);
        boolean result = thisTime && !finished;
        finished = thisTime;
        return result;
    }

    @Override
    public Instruction getInstruction() {
        return nlg.instructionGenerator.createInstruction(nlg.visible);
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final NotFacingPositionAlert other = (NotFacingPositionAlert) obj;
        if (this.targetPosition != other.targetPosition && (this.targetPosition == null || !this.targetPosition.equals(other.targetPosition))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 37 * hash + (this.targetPosition != null ? this.targetPosition.hashCode() : 0);
        return hash;
    }


}
